package br.com.caelum.jdbc;

import java.sql.Connection;
import java.sql.SQLException;

import javax.sql.DataSource;

import org.hsqldb.jdbc.JDBCPool;

public class ConnectionPool {

	private final DataSource	dataSource;

	public ConnectionPool() {
		final JDBCPool jdbcPool = new JDBCPool();
		jdbcPool.setUrl("jdbc:hsqldb:hsql://localhost/loja-virtual");
		jdbcPool.setUser("SA");
		jdbcPool.setPassword("");

		this.dataSource = jdbcPool;
	}

	Connection getConnection() throws SQLException {
//		final Connection connection = DriverManager.getConnection("jdbc:hsqldb:hsql://localhost/loja-virtual", "SA", "");
		final Connection connection = this.dataSource.getConnection();
		return connection;
	}
}
